<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
    <script>
      function add(...values){
        console.log(values.length)
      }
      add(1,2)
      add(1,2,3)
      //得到2, 3


      //箭头函数
      var print = function(obj){
        console.log(obj)
      }
      print("hello")
      var print = obj => console.log(obj);
      print("hello2")

      var sum= function(a, b){
        return a + b
      }
      console.log(sum(1, 2))
      var sum2 = (a, b) => a + b
      console.log(sum2(1, 2))

      var mul = function(a, b){
        var c = a + b;
        return c * c
      }
      console.log(mul(1, 2))
      var mul2 = (a, b) => {
        var c = a + b;
        return c * c
      }
      console.log(mul2(1, 2))

      //箭头函数+解构表达式
      var person = {
        name: 'tom',
        age: 20
      }
      //原来写法
      function print(person){
        console.log(person.name)
      }
      print(person)
      //ES6写法   name 为 person的属性
      var print = ({name}) => console.log(name)
      print(person)

    </script>
	</body>
</html>
